<template >
   <el-dialog :title="title" :close-on-click-modal="false" :before-close="closeDialog" :visible.sync="visible" width="700px" append-to-body dialogDrag>
        <el-form ref="form" :inline="true" :model="form" class="form" size="small" label-width="80px">
            <!-- <el-form-item   label="所属部门"  prop="deptId">   
                <treeselect v-model="form.deptId" :multiple="false" :options="treeData" :normalizer="normalizer"/>
            </el-form-item> -->
            <el-form-item label="用户名" prop="username"> 
                <el-input v-model="form.username" style="width:220px" readonly></el-input>
            </el-form-item>
            <el-form-item label="状态" prop="status">
                <el-radio v-for="(value,key) in statusDicts" :key="key" v-model="form.status" :label="value" disabled>{{ key }}</el-radio>
            </el-form-item>
            <el-form-item label="昵称" prop="nickName"> 
                <el-input v-model="form.nickName" style="width:220px" readonly></el-input>
            </el-form-item>  
            <el-form-item   label="性别" prop="sex">
                <el-radio v-for="(value,key) in sexDicts" :key="key" v-model="form.sex" :label="value" disabled>{{ key }}</el-radio>
            </el-form-item>
            <el-form-item   label="联系电话" prop="phone"> 
                <el-input v-model="form.phone" style="width:220px" readonly></el-input>
            </el-form-item>
            <el-form-item   label="邮箱" prop="email"> 
                <el-input v-model="form.email" style="width:220px" readonly></el-input>
            </el-form-item>
            <!-- <el-form-item   label="角色" prop="roless"> 
                <el-select v-model="form.roless" multiple filterable placeholder="请选择角色">
                    <el-option v-for="item in roles" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
            </el-form-item> -->
            <el-form-item label="备注">
                <el-input type="textarea" v-model="form.note" style="width: 534px;" readonly></el-input>
            </el-form-item>
        </el-form>

        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="closeDialog">关闭</el-button>
        </div>
    </el-dialog>
</template>
<script>
import { selAdmin} from '@/api/user'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default {
    inject:['reload'],
     components: {
        Treeselect
    },
    data() {
        return {
            rowId:'',
            title:'',
            roles: [],
            visible: false,
            treeData:[],
            sexDicts:this.$global.sex,
            statusDicts:this.$global.status,
            form: {
                username:'',
                nickName:'',
                status: '',
                sex: '',
                note:'',
                phone:'',
                email:''
            },
        };
    },
    methods: {
        closeDialog(){
            this.visible = false
            this.rowId = ''
            this.form = {username:'', nickName:'', status: '', sex: '', note:'', phone:'', email:''}
        },
        init(row) {
            this.title = '查看用户'
            !!row && (this.rowId = row.id) && this.findUserById(this.rowId)
            this.$nextTick(() => {
                this.visible = true
            })
        },
        findUserById(id){
            this.apiSelAdminById(id)
        },
        //==========>请求api接口<==========//
        apiSelAdminById(id){
            selAdmin(id).then(res=>{
                if(res.code === 200){
                    this.form ={...res.data}
                }
            },error=>{
                this.$message.error(res.message)
            })
        },
    },
};
</script>
<style scoped>

</style>


